<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}

if($_POST['sub']!=''){
    
    $listorder=$_POST["listorder"];
    if(!empty($listorder)){
     while(list($k,$v)=each($listorder)){
        $data=array("listorder"=>$v);
        $ezhand->update("vote_option_item",$data,'id='.$k);  
            
        
     }  
    }    
    
}


$subjectid=intval($_GET["subjectid"]);
if(empty($subjectid)){
    echo "没有选择调查";
    
    exit;
}
$page = !($_POST['pageNum'])?'1':intval($_POST['pageNum']);
$pagesize= !($_POST['numPerPage'])?'20':intval($_POST['numPerPage']);


if(empty($pagesize)){
    $pagesize=20;
}
$frmnum=($page-1)*$pagesize;
$orderField=trim($_POST["orderField"]);
$orderDirection=trim($_POST["orderDirection"]);
if(empty($orderField)){
    $orderField="subjectid";
}
if(empty($orderDirection)){
    $orderDirection="desc";
}
if($orderField<>""){
    $order=" order by $orderField ".$orderDirection;
}else{
    $order=" order by listorder asc,subjectid desc";
}

$q=trim($_POST['q']);

$total=$ezhand->count("vote_option_item","`title` like '%$q%' and subjectid=".$subjectid);
$row=$ezhand->select_all("vote_option_item",'*','`title` like "%'.$q.'%" and subjectid='.$subjectid.' '.$order.' limit '.$frmnum.','.$pagesize);

?>